package com.luoye.lj.wstool.web;

import com.luoye.lj.wstool.generator.ICodeGenerator;
import com.luoye.lj.wstool.web.entity.WebtEntity;
import com.luoye.lj.wstool.web.entity.WebtField;

/*
 * Created with IntelliJ IDEA.
 * User: Dave Liu
 * Date: 2016/7/7
 * Time: 15:45
 * To change this template use File | Settings | File Templates.
 */
public class JspSearchTargetCodeGenerator implements ICodeGenerator {
    private WebtEntity webtEntity;

    public JspSearchTargetCodeGenerator(WebtEntity webtEntity) {
        this.webtEntity = webtEntity;
    }

    @Override
    public String codeGenerate() {
        String code="";
        int i=0;
        if(this.webtEntity!=null){
            if(this.webtEntity.getFieldList()!=null){
                for(WebtField webtField:this.webtEntity.getFieldList()){
                    if(i%2==0){
                        code+="            <div class=\"row screen-group\">\n";
                    }
                    code+="" +
                            "                <div class=\"col-lg-6 col-md-6 col-sm-6 col-xs-12 right-group\">\n" +
                            "                    <div class=\"input-group\">\n" +
                            "                        <span class=\"input-group-addon\">"+webtField.getDescription()+"：</span>\n" +
                            "                        <input class=\"form-control\" type=\"text\" id=\""+webtField.getFieldName()+"\"/>\n" +
                            "                    </div>\n" +
                            "                </div>\n";
                    if(i%2==1){
                        code+="            </div>\n";
                    }
                    i++;
                }
            }
        }
        if(i%2==1){
            code+="            </div>\n";
        }
        return code;
    }
}
